package com.fxu.tpl.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fxu.framework.core.enums.EnumValid;
import com.fxu.framework.core.sql.SEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

import javax.validation.constraints.Size;
import com.fxu.tpl.enums.LogTrackTypeEnum;
import java.util.Date;

/***
 * <p>yuye</p>
 * 日志记录表：[log_track]的数据实体类
 * @author fangxu
 * @version 2022-03-11
 ***/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "LogTrack", description = "日志记录")
@TableName("fxu_log_track")
public class LogTrack extends SEntity<LogTrack> implements Serializable {
/*=== 自动生成代码 开始 ===*/
    private static final long serialVersionUID = 7086318278577958866L;

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "自增ID")
    private Long id;

    @ApiModelProperty(value = "类型[INFO:信息,WARN:警告,ERROR:异常]")
    @Size(max = 8, message = "类型的长度必须小于8位")
    @EnumValid(target = LogTrackTypeEnum.class, message = "类型的值必须为[INFO:信息,WARN:警告,ERROR:异常]")
    private String type;

    @ApiModelProperty(value = "说明")
    @Size(max = 64, message = "说明的长度必须小于64位")
    private String mark;

    @ApiModelProperty(value = "方法")
    @Size(max = 128, message = "方法的长度必须小于128位")
    private String method;

    @ApiModelProperty(value = "参数")
    @Size(max = 512, message = "参数的长度必须小于512位")
    private String params;

    @ApiModelProperty(value = "浏览器")
    @Size(max = 64, message = "浏览器的长度必须小于64位")
    private String browser;

    @ApiModelProperty(value = "操作系统")
    @Size(max = 64, message = "操作系统的长度必须小于64位")
    private String os;

    @ApiModelProperty(value = "IP地址")
    @Size(max = 64, message = "IP地址的长度必须小于64位")
    private String ip;

    @ApiModelProperty(value = "操作员")
    @Size(max = 64, message = "操作员的长度必须小于64位")
    private String admin;

    @TableField(select = false)
    @ApiModelProperty(value = "异常信息")
    private String exception;

    @ApiModelProperty(value = "开始时间")
    private Long startTime;

    @ApiModelProperty(value = "结束时间")
    private Long endTime;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    public String getTypeText() {
        return LogTrackTypeEnum.desc(type);
    }
/*=== 自动生成代码 结束 ===*/
}
